
export default {
  formateCustom (custom) {
    let tableData = []
    console.log(custom.nick_name, 'custom.nick_name')
    if (custom.nick_name) {
      tableData = tableData.concat({
        text: '昵称',
        value: custom.nick_name
      })
    }
    tableData = tableData.concat[
      {
        text: '家长名字',
        value: custom.parent_name
      },
      {
        text: '性别',
        value: 'sex'
      },
      {
        text: '手机号码',
        value: custom.mobile_num
      },
      {
        text: '所在地址',
        value: custom.district
      },
      {
        text: '所在行业',
        value: custom.parent_industry
      },
      {
        text: '客户来源',
        value: 'source_id'
      },
      {
        text: '客户类型',
        value: 'custom_type'
      },
      {
        text: '跟进状态',
        value: 'status'
      },
      {
        text: '详细地址',
        value: custom.address
      }
    ]
    return tableData
  },
  formateCustomFromVal (row, column) {
    // console.log(JSON.stringify(row))
    let value = ''
    const customDetail = this.customDetail
    if (row.value === 'source_id') {
      value = this.formateSources(customDetail)
    } else if (row.value === 'status') {
      value = this.formateStatus(customDetail)
    } else if (row.value === 'custom_property') {
      value = this.formateProperty(customDetail)
    } else if (row.value === 'custom_type') {
      value = this.formateCustomType(customDetail)
    } else if (row.value === 'sex') {
      value = this.formateSex(customDetail)
    } else {
      value = row.value
    }
    return value
  },
  formateStatus (row, column) {
    return row.custom_status ? this.dataDictionary['custom_status'][row.custom_status] : (column ? '无' : '请选择')
  },
  formateSources (row, column) {
    return row.source_id ? this.dataDictionary['custom_source'][row.source_id] : (column ? '无' : '请选择')
  },
  formateProperty (row, column) {
    // console.debug(JSON.stringify(row), row.custom_property, row.custom_property ? this.dataDictionary['custom_propety'][row.custom_property] : (column ? '无': '请选择'))
    return row.custom_property ? this.dataDictionary['custom_propety'][row.custom_property] : (column ? '无' : '请选择')
  },
  formateSex (row, column) {
    return row.sex === 0 ? '男' : '女'
  },
  formateCustomType (row, column) {
    // console.log(JSON.stringify(row), row.custom_type)
    return row.custom_type ? this.dataDictionary['custom_type'][row.custom_type] : (column ? '无' : '请选择')
  },
  setSizeInputVal (val) {
    const sizeInput = this.$refs.pagination.$el.getElementsByClassName('el-input__inner')[0]
    val = val + ' ' + '条/页'
    sizeInput.value = val
  },
  changeVal (el, val) {
    // console.log(el, val)
    el.$el.getElementsByClassName('el-input__inner')[0].value = val || '请选择'
  }
}
